 package com.withoutwords.engine.social;

import android.app.Activity;

public class SocialEngine {
	//for singleton implementation
	private SocialEngine()
	{
		loginNetowrk = SocialNetwork.Facebook;
	}
	static SocialEngine _engine;
	public static SocialEngine getSocialEngine()
	{
		if(_engine == null)
		{
			_engine = new SocialEngine();
			
		}
		return _engine;
	}
	
	//Class members and functions
	SocialNetwork loginNetowrk;
	ISocialNetworkController[] socialNetworksControllers = new ISocialNetworkController[SocialNetwork.values().length];
	public ISocialNetworkController getSocialNetworkController(SocialNetwork network)
	{
		int index  = network.ordinal();
		if(socialNetworksControllers[index] == null)
		{
			socialNetworksControllers[index] = createSocialNetworkController(network);
		}
		return socialNetworksControllers[index];
	}
	 ISocialNetworkController createSocialNetworkController(SocialNetwork network)
	{
		switch(network)
		{
		case Facebook:
			return new FacebookController();
		}
		
		return null;
	}
	
	 public boolean isLoggenIn(Activity activity)
	 {
		 boolean isLoggedIn = false;
		 ISocialNetworkController loginNetworkController = getSocialNetworkController(loginNetowrk);
		 if(loginNetworkController != null)
		 {
			 isLoggedIn = loginNetworkController.isLoggenIn( activity);
		 }
		 return isLoggedIn;
	 }

	 
}
